<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@page import="com.framework.util.Const"%>
	<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html>
<html class="no-js">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>提现</title>
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <meta name="format-detection" content="telephone=no" />
    <jsp:include page="/jsp/inc_head.jsp"></jsp:include>
    <style>
        .cztop{
            border-bottom:1px solid #eee;
            padding:12px 3.5%;
            font-size:12px;
            color:#a7a7a7;
        }
    </style>
</head>
<body>
<section class="am-g am-text-sm">
    <div class="am-u-sm-12 am-pad-none cztop">
        <div class="">
            提现金额
        </div>
        <div class="inputTXnum">
            <input id="amount" type="number" class="TX" placeholder="" value="" onkeyup= "if(!/^[0-9]{1,}(?:.[0-9]{0,2})?$/.test(this.value)){$('.innerNum').html('输入金额'); this.value=0.00;}"/>
            <span class="TXTextYuan">元</span>
        </div>
    </div>
    <div class="am-u-sm-12 am-pad-none keTxTip">
        当前可提现久零币<span id="withdrawals">0.00</span>元
    </div>
</section>
<div class="am-modal am-modal-alert" tabindex="-1" id="my-alert">
    <div class="am-modal-dialog">
        <div class="am-modal-hd" id="alert_title"></div>
        <div class="am-modal-bd" id="alert_message"></div>
        <div class="am-modal-footer">
            <span class="am-modal-btn" id="sure">确定</span>
        </div>
    </div>
</div>


<!--footer-->
<a href="javascript:void(0);" class="botBtn sqtkCxsq" style="width: 640px;left: 50%; margin-left: -320px;" onClick="toApplyWithDrawal();">立即申请提现</a>


<script>
    var ajaxpath="${pageContext.request.contextPath}";
    $(function(){
        var url=ajaxpath+"/coin/doQueryAmountForWithDrawals.do";
        $.get(url,function(data){
            if(data!=''&&data!=null)
                $("#withdrawals").html(data);
        });
    });
</script>

<script type="text/javascript">
    $(document).ready(function() {
        //敲击按键时触发
        $("input.TX").bind("keypress", function(event) {
            var event= event || window.event;
            var getValue = $(this).val();
            //控制第一个不能输入小数点"."
            if (getValue.length == 0 && event.which == 46) {
                // alert(1)
                event.preventDefault();
                return;
            }
            //控制只能输入一个小数点"."
            if (getValue.indexOf('.') != -1 && event.which == 46) {
                event.preventDefault();
                //alert(1)
                return;
            }
            //控制只能输入的值
            if (event.which && (event.which < 48 || event.which > 57) && event.which != 8 && event.which != 46 ) {
                event.preventDefault();
                return;
            }
        });
        //失去焦点是触发
        $("input.TX").bind("blur", function(event) {
            var value = $(this).val(), reg = /\.$/;
            if (reg.test(value)) {
                value = value.replace(reg, "");
                $(this).val(value);
            }
        });
    });

    //提交退款申请单
    function toApplyWithDrawal(){
        var amount =$("#amount").val();
        var withdrawals =$("#withdrawals").html();
        if(amount==null||amount==''){
            $("#alert_message").html("请输入提现金额！");
            $("#my-alert").modal('open');
            return;
        }
        if(amount*1<=0||amount*1>withdrawals*1){
            $("#alert_message").html("余额不足,申请提交失败!");
            $("#my-alert").modal('open');
            return;
        }
        var url=ajaxpath+"/coin/toApplyWithDrawal.do?amount="+amount;
        $.get(url,function(data){
            if(data.code==200){
                $("#alert_message").html("申请提交成功,将于1-2个工作日内完成审核,请耐心等待！");
                $("#my-alert").modal('open');
                $("#sure").click(function(){
                    $("#my-alert").modal('close');
                });
                return;
            }else{
                $("#alert_message").html("申请提交失败，请稍后重试或联系管理员！");
                $("#my-alert").modal('open');
                return;
            }
        });
    }
</script>
</body>
</html>
